import service from "~/utils/request";

// 分页获取认证信息
export const PageSecret = (query) => {
  return service({
    url: "/cmdb/pageSecret",
    method: "get",
    params: query,
  });
};

// 删除认证信息
export const DeleteSecret = (instanceid) => {
  return service({
    url: `/cmdb/${instanceid}/deleteSecret`,
    method: "delete",
  });
};

// 批量删除认证信息
export const DeleteSecrets = (data) => {
  return service({
    url: `/cmdb/deleteSecrets`,
    method: "post",
    data,
  });
};

// 创建认证信息
export const CreateSecret = (data) => {
  return service({
    url: `/cmdb/createSecret`,
    method: "post",
    data,
  });
};

// 修改认证信息
export const UpdateSecret = (data) => {
  return service({
    url: `/cmdb/updateSecret`,
    method: "post",
    data,
  });
};

// 获取主机组树
export const GetHostGroupTree = () => {
  return service({
    url: "/cmdb/getHostGroupTree",
    method: "get",
  });
};

// 获取主机组列表
export const GetHostGroupList = () => {
  return service({
    url: "/cmdb/getHostGroupList",
    method: "get",
  });
};

// 创建子级别主机组
export const CreateSonHostGroup = (data) => {
  return service({
    url: `/cmdb/createSonHostGroup`,
    method: "post",
    data,
  });
};

// 创建同级主机组
export const CreateHostGroup = (data) => {
  return service({
    url: `/cmdb/createHostGroup`,
    method: "post",
    data,
  });
};

// 编辑主机组
export const UpdateHostGroup = (data) => {
  return service({
    url: `/cmdb/updateHostGroup`,
    method: "put",
    data,
  });
};

// 删除主机组
export const DeleteHostGroup = (instanceid) => {
  return service({
    url: `/cmdb/${instanceid}/deleteHostGroup`,
    method: "delete",
  });
};

// 获取认证信息列表
export const GetSecretList = () => {
  return service({
    url: "/cmdb/getSecretList",
    method: "get",
  });
};

// 分页获取主机列表
export const GetPageHosts = (query) => {
  return service({
    url: `/cmdb/${query.groupID}/pageHost`,
    method: "get",
    params: query,
  });
};

// 创建主机
export const CreateHost = (data) => {
  return service({
    url: `/cmdb/createHost`,
    method: "post",
    data,
  });
};

// 修改认证信息
export const UpdateHost = (data) => {
  return service({
    url: `/cmdb/updateHost`,
    method: "post",
    data,
  });
};

// 删除主机
export const DeleteHost = (instanceid) => {
  return service({
    url: `/cmdb/${instanceid}/deleteHost`,
    method: "delete",
  });
};

// 批量删除主机
export const DeleteHosts = (data) => {
  return service({
    url: `/cmdb/deleteHosts`,
    method: "post",
    data,
  });
};

// 批量获取主机信息
export const GetHosts = () => {
  return service({
    url: `/cmdb/getHostsList`,
    method: "get",
  });
};
